﻿<!DOCTYPE html>

<html>

	<head>
		<meta charset="utf-8">
		<title>LMB-SVN - 用户添加</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<script type="text/javascript" src="${httpRootPath}/resources/main/js/jquery-1.9.1.min.js"></script>
		<script type="text/javascript" src="${httpRootPath}/resources/main/js/jquery.form.js"></script>
		<script src="${httpRootPath}/resources/layui/layui.js" charset="utf-8"></script>
		<link rel="stylesheet" href="${httpRootPath}/resources/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="${httpRootPath}/resources/main/css/global.css">
	</head>

	<body>
	<#include "/z_head.html"/>
	<div class="layui-main site-inline">
		<div class="site-content">
			<h1 class="site-h1">添加用户</h1>
			<div class="layui-main">
				<blockquote class="layui-elem-quote">
					<form class="layui-form" action="data/user_editor" id="useraddform">
						<div class="layui-form-item">
							<label class="layui-form-label">用户名：</label>
							<div class="layui-input-block">
								<input type="text" name="f_username" id="f_username" placeholder="请输入用户名" class="layui-input" onchange="">
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">姓　名：</label>
							<div class="layui-input-block">
								<input type="text" name="f_realname" id="f_realname" placeholder="请输入姓名" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">密　码：</label>
							<div class="layui-input-block">
								<input type="text" name="f_password" id="f_password" placeholder="请输入密码" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">角　色：</label>
							<div class="layui-input-block" id="f_rolediv">
								<select name="f_role" id="f_role" lay-filter="aihao">
									<option value=""></option>
									<option value="admin">admin</option>
								</select>
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-input-block">
								<button type="button" class="layui-btn" onclick="formsubmit()">创建</button>
								<button type="reset" class="layui-btn layui-btn-primary">重置</button>
							</div>
						</div>
					</form>
				</blockquote>
			</div>
		</div>
	</div>

	<script>
        layui.use(['form', 'layedit', 'laydate', 'element'], function(){
            var form = layui.form()
                ,layer = layui.layer
                ,layedit = layui.layedit
                ,laydate = layui.laydate
                ,element = layui.element();
        });

        function formsubmit(){
            var f_username = $("#f_username").val();
            var f_realname = $("#f_realname").val();
            var f_password = $("#f_password").val();
            var f_role = $("#f_role").val();
            if(f_username == null || f_username == ""){
                $("#f_username").focus();
                layer.tips('请输入用户名', '#f_username');
                return;
            }
            if(f_realname == null || f_realname == ""){
                $("#f_realname").focus();
                layer.tips('请输入姓名', '#f_realname');
                return;
            }
            if(f_password == null || f_password == ""){
                $("#f_password").focus();
                layer.tips('请输入密码', '#f_password');
                return;
            }
            if(f_role == null || f_role == ""){
                $("#f_role").focus();
                layer.tips('请选择角色', '#f_rolediv');
                return;
            }
            $('#useraddform').ajaxSubmit({
                dataType:'html',
                timeout:0,
                success:showResponse,
                error:showError
            });// 提交表单
        }

        function showResponse(json){
            var obj = $.parseJSON(json);
            var success = obj.success;
            var message = obj.message;
            if(success){
                window.location.href = "userManage.htm";
            }else{
                layer.alert(message)
            }
        }
        function showError(xhr, ajaxOptions, thrownError) {
            layer.alert('网络异常')
        }
	</script>
	</body>
</html>